package com.whsr.readservice.controller;

import com.whsr.readservice.dto.ArticleRequest;
import com.whsr.readservice.dto.CategoryRequest;
import com.whsr.readservice.service.ArticleService;
import com.whsr.readservice.service.CategoryService;
import com.whsr.readservice.vo.Article;
import com.whsr.readservice.vo.Category;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/server/category")
public class CategoryController {

    @Autowired
    private CategoryService categoryService;

    /**
     * 根据pId 获取作品类型集合
     * @param pId
     * @return
     */
    @RequestMapping(value = "/getCategoryByPid/{pId}",method = RequestMethod.GET)
    public List<Category> getCategoryByPid(@PathVariable Integer pId){
        return categoryService.getCategoryByPid(pId);
    }


    /**
     *  获取作品类型集合
     * @param categoryRequest
     * @return
     */
    @RequestMapping(value = "/getCategoryList",method = RequestMethod.POST)
    public List<CategoryRequest> getCategoryList(@RequestBody CategoryRequest categoryRequest){
        return categoryService.getCategoryList(categoryRequest);
    }

    @RequestMapping("/getAllCategory")
    @ResponseBody
    public Object getAllCategory(){
        return categoryService.getAllCategory();
    }

}
